/*
 * @(#)GenerateWorldScreen.java     14/08/02
 * 
 * Author             Rick Wilson
 * Copyright (c) 2014 Rick Wilson
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of 'Taareekah' nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */



package gui;

//~--- non-JDK imports --------------------------------------------------------

import com.jme3.app.SimpleApplication;
import com.jme3.asset.AssetManager;
import com.jme3.renderer.ViewPort;
import com.jme3.scene.Node;

import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.TextField;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

/**
 *
 * @author rick
 */
public class GenerateWorldScreen implements ScreenController {

    // This references must be held or the terrain wont show up after being generated

    /** Field description */
    private Nifty	nifty;

    /** Field description */
    private Screen	screen;

    /** Field description */
    private ViewPort	viewPort;

    /** Field description */
    private Node	rootNode;

    /** Field description */
    private Node	guiNode;

    /** Field description */
    private AssetManager	assetManager;

    /** Field description */
    private SimpleApplication	app;

    /** Field description */
    private TextField	generate_world_name_textfield;

    /** Field description */
    private TextField	generate_world_seed_textfield;

    /** Field description */
    private TextField	generate_world_size_textfield;

    /**
     *
     * @param app
     */
    public GenerateWorldScreen(SimpleApplication app) {
	this.rootNode		= app.getRootNode();
	this.viewPort		= app.getViewPort();
	this.guiNode		= app.getGuiNode();
	this.assetManager	= app.getAssetManager();
	this.app		= app;
    }

    /**
     *
     * @param nifty
     * @param screen
     */
    public void bind(Nifty nifty, Screen screen) {
	this.nifty			= nifty;
	this.screen			= screen;
	generate_world_name_textfield	= screen.findNiftyControl("generate_world_name_textfield", TextField.class);
	generate_world_seed_textfield	= screen.findNiftyControl("generate_world_seed_textfield", TextField.class);
	generate_world_size_textfield	= screen.findNiftyControl("generate_world_size_textfield", TextField.class);
	generate_world_size_textfield.setText("0");
	generate_world_seed_textfield.setText("0");
	generate_world_name_textfield.setText("");
    }

    /**
     *
     */
    public void onStartScreen() {}

    /**
     *
     */
    public void onEndScreen() {}

    /**
     *
     * @param screen_name
     */
    public void goToScreen(String screen_name) {
	this.nifty.gotoScreen(screen_name);
    }

    /*
     * public void generateWorld() throws Exception {
     *   try {
     *       world_gen.generate("FART", "assets/GameDefs/testParamSet.xml");
     *
     *       world.initFromWorldGenerator(world_gen);
     *       goToScreen("worldViewerScreen");
     *       //world.serializeToFile("world.ser");
     *       //rootNode.attachChild(world.generateDrawableTerrain(assetManager, app.getCamera()));
     *   } catch (Exception e) {
     *       Logger.getLogger(GenerateWorldScreen.class.getName()).log(Level.SEVERE, "Couldnt generate terrain", e);
     *       throw e;
     *   }
     *
     * }
     */
}


//~ Formatted by Jindent --- http://www.jindent.com
